package com.eusoft.grades.school;
/**
 * @author Nick Eubanks
 * 
 * Copyright (C) 2010 Android Infinity (http://www.androidinfinity.com)
 *
 */
public class PointsObject implements Comparable {
	public double earned;
	public double worth;

	public PointsObject(double e, double w) {
		this.earned = e;
		this.worth = w;
	}

	@Override
	public int compareTo(Object o) {
		if (this.earned / this.worth > ((PointsObject) o).earned
				/ ((PointsObject) o).worth)
			return 1;
		else if (this.earned / this.worth < ((PointsObject) o).earned
				/ ((PointsObject) o).worth)
			return -1;
		return 0;
	}

	public double getGrade() {
		if (this.worth == 0)
			return this.earned;
		else
			return (this.earned / this.worth) * 100;
	}

}
